package com.njwb.feign.fallback;

import com.njwb.feign.client.UserServiceClient;
import com.njwb.json.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
@Slf4j
public class UserServiceClientFallbackFactory implements FallbackFactory<UserServiceClient> {
    @Override
    public UserServiceClient create(Throwable cause) {
        return new UserServiceClient() {
            @Override
            public ResponseResult findById(Integer id) {
                log.error("查询用户失败",cause);
                ResponseResult responseResult = new ResponseResult("503","服务不可用",null);
                return responseResult;
            }
        };
    }
}
